using System.IO;
using System.Threading.Tasks;
using MalwareMultiScan.Api.Data.Models;

namespace MalwareMultiScan.Api.Services.Interfaces
{
    /// <summary>
    /// Scan result service.
    /// </summary>
    public interface IScanResultService
    {
        /// <summary>
        /// Create scan result.
        /// </summary>
        /// <returns>Scan result entry with id.</returns>
        Task<ScanResult> CreateScanResult();

        /// <summary>
        /// Get scan result.
        /// </summary>
        /// <param name="id">Result id.</param>
        /// <returns>Scan result entry with id.</returns>
        Task<ScanResult> GetScanResult(string id);

        /// <summary>
        /// Update scan result entry.
        /// </summary>
        /// <param name="resultId">Result id.</param>
        /// <param name="backendId">Backend id.</param>
        /// <param name="duration">Duration.</param>
        /// <param name="completed">Completion status.</param>
        /// <param name="succeeded">Indicates that scanning completed without error.</param>
        /// <param name="threats">Detected names of threats.</param>
        Task UpdateScanResultForBackend(string resultId, string backendId, long duration,
            bool completed = false, bool succeeded = false, string[] threats = null);

        /// <summary>
        /// Queue URL for scanning.
        /// </summary>
        /// <param name="result">Result entry.</param>
        /// <param name="fileUrl">Remote URL.</param>
        Task QueueUrlScan(ScanResult result, string fileUrl);

        /// <summary>
        /// Store file.
        /// </summary>
        /// <param name="fileName">File name.</param>
        /// <param name="fileStream">File stream.</param>
        /// <returns>Unique file id.</returns>
        Task<string> StoreFile(string fileName, Stream fileStream);

        /// <summary>
        /// Obtain file.
        /// </summary>
        /// <param name="id">Unique file id.</param>
        /// <returns>Seekable file stream opened for reading.</returns>
        Task<Stream> ObtainFile(string id);
    }
}